package com.bw.day03.quan

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.alibaba.android.arouter.facade.annotation.Route
import com.bw.base.net.entity.MyTabEntity
import com.bw.base.net.mvvm.BaseViewActivity
import com.bw.day03.R
import com.bw.day03.adapter.VpAdapter
import com.bw.day03.databinding.ActivityQuanBinding
import com.bw.day03.order.Order1Fragment
import com.bw.day03.order.Order2Fragment
import com.bw.day03.order.Order3Fragment
import com.flyco.tablayout.listener.CustomTabEntity
import com.flyco.tablayout.listener.OnTabSelectListener

@Route(path = "/app/QuanActivity")
class QuanActivity : BaseViewActivity<ActivityQuanBinding>() {
    var list=mutableListOf<Fragment>()
    var tabs=arrayListOf<CustomTabEntity>()
    lateinit var vpAdapter: VpAdapter
    override fun initView() {
        list.add(UseFragment())
        list.add(UnUseFragment())
        vpAdapter= VpAdapter(this,list)
        binding.vp.adapter=vpAdapter
        tabs.add(MyTabEntity("已领取",0,0))
        tabs.add(MyTabEntity("未使用/不可使用",0,0))
        binding.common.setTabData(tabs)
        binding.vp.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback(){
            override fun onPageSelected(position: Int) {
                super.onPageSelected(position)
                binding.common.currentTab=position
            }
        })
        binding.common.setOnTabSelectListener(object : OnTabSelectListener{
            override fun onTabSelect(position: Int) {
                binding.vp.currentItem=position
            }

            override fun onTabReselect(position: Int) {

            }
        })

    }

    override fun initData() {

    }

    override fun getLayoutId(): Int = R.layout.activity_quan

}